#include "stopDownloadMovieMessage.h"
#include "jsonUtils.h"

StopDownloadMovieMessage::StopDownloadMovieMessage(MtpProtocol* packet) : MtpMessage(packet),movieId(0)
{
}

StopDownloadMovieMessage::StopDownloadMovieMessage(const int64_t& movieId) : MtpMessage(new MtpProtocol(L"stopDownloadMovie")), movieId(movieId)
{
}

void StopDownloadMovieMessage::decodeBody()
{
	MtpMessage::decodeBody();
	if (!jsonContent.empty()) {
		JsonDoc doc(rapidjson::kObjectType);
		doc.Parse(jsonContent.c_str());
		JsonUtils::loadLong(doc, L"movieId", movieId);
	}
}

void StopDownloadMovieMessage::encodeBody()
{
	JsonDoc doc(rapidjson::kObjectType);
	doc.AddMember(L"movieId", movieId,doc.GetAllocator());
	jsonContent = JsonUtils::jsonStr(doc);
	MtpMessage::encodeBody();
}

const int64_t& StopDownloadMovieMessage::getMovieId() const
{
	return movieId;
}
